class CookieGenerator:
	def __init__(self):
		self.active_cookies = {}
		self.free_cookies = []

	def get_cookie(self):
		if len(self.free_cookies) == 0: #Allocate new cookie
			cno = len(self.active_cookies) + 1
			self.active_cookies[cno] = cno
			return cno
		else:
			cno = self.free_cookies.pop()
			self.active_cookies[cno] = cno
			return cno
	
	def remove_cookie(self, cno):
		if cno in self.active_cookies:
			del self.active_cookies[cno]
			self.free_cookies.append(cno)
		else:
			print 'Error: Cookie number not found in list of active cookies'
